package com.mornd.gulimall.ware.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.math.BigDecimal;

import com.mornd.gulimall.common.core.entity.PageEntity;
import com.mornd.gulimall.common.core.validation.UpdateGroup;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * <p>
 *
 * </p>
 *
 * @author mornd
 * @since 2023-07-29
 */
@Getter
@Setter
@TableName("wms_purchase_detail")
public class PurchaseDetail extends PageEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @NotNull(groups = UpdateGroup.class)
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 采购单id
     */
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private Long purchaseId;

    /**
     * 采购商品id
     */
    @NotBlank
    private String skuId;

    /**
     * 采购数量
     */
    @NotNull
    @Min(value = 1, message = "数量不得低于1")
    private Integer skuNum;

    /**
     * 采购金额
     */
    @NotNull
    @Min(value = 0, message = "金额不能小于0")
    private BigDecimal skuPrice;

    /**
     * 仓库id
     */
    @NotNull
    private Long wareId;

    /**
     * 状态[0新建，1已分配，2正在采购，3已完成，4采购失败]
     */
    @NotNull
    @Range(min = 0, max = 4) // 允许 null 值，需要添加 @NotNull
    private Integer status;

    @TableField(exist = false)
    private String wareName;

    /**
     * 搜索
     */
    @TableField(exist = false)
    private String key;

}
